package com.douqu.game.battle.entity.aobject;

import com.douqu.game.battle.util.BattleUtils;
import com.douqu.game.core.config.common.Position;
import com.douqu.game.core.factory.DataFactory;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-03-14 11:39
 */
public class LastSendPosition {

    private String type;

    private Position position;

    private long sendTime;

    public LastSendPosition(String type, Position position)
    {
        this.type = type;
        this.position = position;
        this.sendTime = DataFactory.currentTime;
    }

    public void update(String type, Position position)
    {
        this.type = type;
        this.position = position;
        this.sendTime = DataFactory.currentTime;
    }

    public boolean isNeedSend(String type, Position position)
    {
        if(!this.type.equals(type))
            return true;

        if(DataFactory.currentTime - sendTime >= 2000 && BattleUtils.getDistance(this.position, position) >= 2.5)
            return true;

        return false;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Position getPosition() {
        return position;
    }

    public void setPosition(Position position) {
        this.position = position;
    }

    public long getSendTime() {
        return sendTime;
    }

    public void setSendTime(long sendTime) {
        this.sendTime = sendTime;
    }
}
